#ifndef AD_ONECLASSINFO_H
#define AD_ONECLASSINFO_H

#include <QWidget>
#include <QComboBox>

namespace Ui {
class AD_OneClassInfo;
}

class AD_OneClassInfo : public QWidget
{
    Q_OBJECT

public:
    explicit AD_OneClassInfo(QWidget *parent = nullptr);
    ~AD_OneClassInfo();

    // add,update,view
    void setMode(const QString & mode = "add");

    void setClassListComboBox(QString where = "");

    void setStudentTableFormClassId(int id);

    void setCoursesTableFormClassId(int id);

    int getClassId();

    int getCounID();

    QString getClassName();

    void updateForAdd();

    QStringList getStudents();

private slots:
    void on_pushButtonAddCourse_clicked();

    void on_pushButtonDeleteCourse_clicked();

    void on_pushButtonAddStudent_clicked();

    void on_pushButtonDeleteStudent_clicked();


    void on_pushButtonOK_clicked();

    void on_pushButton_3_clicked();

    void on_pushButton_7_clicked();

    void on_pushButtonOK_2_clicked();

    void on_pushButtonUpdate_clicked();

    void on_comboBoxClassView_activated(int index);

    void on_pushButton_clicked();

private:
    void setCombo(QComboBox* combo, QList<DB_CreateClassInfo::T_Info> data);

    void setTableDataFromClassId(int classID);

    QComboBox* getCoursesComboBox();

    QComboBox* getTeachersComboBox();

    bool classCreate(QSqlQuery * qu);

    bool enrollmentCreate(QSqlQuery * qu);

    bool studentsCreate(QSqlQuery * qu);

    bool enrollmentDelete(QSqlQuery * qu);

    bool studentsDelete(QSqlQuery * qu);

    bool updateClassConsultantID(QSqlQuery * qu);

private:
    Ui::AD_OneClassInfo *ui;

    QString m_mode;

    DB_CreateClassInfo m_allCreateInfo;

    // QWidget interface
protected:
    virtual void showEvent(QShowEvent *event) override;
};

#endif // AD_ONECLASSINFO_H
